package config

import (
	"github.com/spf13/viper"
)

func initEnvironment() {
	//设置默认环境便利
	setDefaultEnvironment()
	//连接已存在的且与默认环境变量有交集的环境变量
	viper.AutomaticEnv()
	//获取环境变量的值
	GetConfigVariate()
}

func setDefaultEnvironment() {
	viper.SetDefault("LOG_LEVEL", "debug")
	viper.SetDefault("PORT", ":80")
	viper.SetDefault("TOKEN", "WeiPublishChat")
}

func GetConfigVariate() {
	LogLevel = viper.GetString("LOG_LEVEL")
	Port = viper.GetString("PORT")
	Token = viper.GetString("TOKEN")
}
